package com.sh.weblogspringboot.web.service.impl;

import com.sh.weblogspringboot.common.domain.dos.BlogSettingsDO;
import com.sh.weblogspringboot.common.domain.mapper.BlogSettingsMapper;
import com.sh.weblogspringboot.common.enums.ResponseCodeEnum;
import com.sh.weblogspringboot.common.exception.BizException;
import com.sh.weblogspringboot.common.util.Response;
import com.sh.weblogspringboot.web.convert.BlogSettingsConvert;
import com.sh.weblogspringboot.web.model.vo.FindBlogSettingsDetailRspVO;
import com.sh.weblogspringboot.web.service.BlogSettingsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author songHai
 * @Classname BlogSettingsServiceImpl
 * @Description
 * @Date 2025/4/12 1:23
 */
@Service
@Slf4j
public class BlogSettingsServiceImpl implements BlogSettingsService {

    @Autowired
    private BlogSettingsMapper blogSettingsMapper;

    @Override
    public Response findDetail() {
        BlogSettingsDO blogSettingsDO = blogSettingsMapper.selectById(1L);
        if (Objects.isNull(blogSettingsDO)) {
            throw new BizException(ResponseCodeEnum.USER_INFO_NOT_FOUND);
        }
        // DO 转 VO
        FindBlogSettingsDetailRspVO vo = BlogSettingsConvert.INSTANCE.converDO2VO(blogSettingsDO);

        return Response.success("查询成功", vo);
    }
}
